import { defineStore } from 'pinia';
import { pinia } from '@/store';

interface StationInfo {
  stcd?: string;
  deviceType?: string | number;
}

interface StationDataState {
  stationData: StationInfo | null | undefined;
}

export const useStationDataStore = defineStore({
  id: 'app-stationData',
  state: (): StationDataState => ({
    stationData: null,
  }),
  getters: {
    getStationData(): StationInfo {
      return this.stationData || {};
    },
  },
  actions: {
    setStationData(data: any) {
      this.stationData = data ? data : '';
    },
  },
});

// Need to be used outside the setup
export function useStationDataStoreWithOut() {
  return useStationDataStore(pinia);
}
